package com.hzsai.mininote.entity;

/**
 * @author hzsai
 * @date 2020/1/8 14:30
 * @usage:
 */
public enum  NoteStateEnum {

    /**
     * 0  --> public
     * 1  --> private
     * 2  --> unknown
     */

    PUBLIC(0), PRIVATE(1), UNKNOWN(2);

    private int state;
    private static final int len = 2;

    NoteStateEnum(int state) {
        this.state = state;
    }

    public int getId() {
        return this.state;
    }

    public String getEnumType() {
        return this.name().toString();
    }

    public static NoteStateEnum getNoteEnumFromId(int id) {
        if (id < 0 || id >= NoteStateEnum.values().length)
            return NoteStateEnum.values()[getLen() - 1];

        return NoteStateEnum.values()[id];
    }

    public static int getLen() {
        return NoteStateEnum.values().length;
    }
}
